<?php
require_once 'includes/haut.php';
acces($niveau,1);

require_once 'modules/gestionMateriel.php';
require_once 'includes/donneesFormulaires.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Suppression du mat&eacute;riel</title>



		<?php include('includes/headLinks.php');?>
		<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
		<script type="text/javascript" src="js/triTable.js"></script>
		<script type="text/javascript" src="js/autocompletionMat.js"></script>
	</head>
<body>
	<div id="entete">




	<?php include('includes/entete.php'); ?>
	</div>

	<div id="navigation">




	<?php include('includes/navigation.php'); ?>
	</div>

	<div id="principal">

			<h2>Gestion du mat&eacute;riel</h2>

			<form action="rechercheMat.php" method="post" id="formRecherche">
				<div class="recherche">
					<input type="search" name= "recherche" id="recherche"/>
					<input type="submit" name="rechercher" value="Rechercher" />
					<input type="hidden" name="action" value="rechercher" />
					<div class="suggestionsBox" id="suggestions">
			 			<img src="images/icones/upArrow.png"  alt="upArrow" />   
						<div class="suggestionList" id="autoSuggestionsList">
						</div>
					</div>
				</div>
			</form>

			<form action="supprMateriel.php" method="post">
			<div class="info">

			<?php
			if(isset($nbSuppr)) {
				if($nbSuppr==1)
				echo ($nbSuppr.' entr&eacute;e a &eacute;t&eacute; supprim&eacute;e');
				else
				echo ($nbSuppr.' entr&eacute;es ont &eacute;t&eacute; supprim&eacute;es');
			}	?>
			</div>
			<div class="error">

			<?php
			if(isset($nbErr)&&$nbErr>0){
				if($nbErr==1)
				echo ($nbErr." mat&eacute;riel est r&eacute;serv&eacute;, il ne peut &ecirc;tre supprim&eacute;.");
				else
				echo ($nbErr." mat&eacute;riels sont r&eacute;serv&eacute;s, ils ne peuvent &ecirc;tre supprim&eacute;s.");
			}

			?>
			</div>
			
							
			<?php 


			$titres=array('Type', 'Niveau', 'Marque', 'Taille', 'Mod&egrave;le');
			
			if (!isset ($_GET['act'])){
				header("Location:indexAdmin.php");
				exit();
			}
			else {
				$act = $_GET['act'];
				$liens = getLiens($tabType, $act);
			}
			?>		
			<div class="liens">
				<a href="supprMateriel.php?act=<?php echo $liens[0]; ?>" class="lienG"><?php echo $liens[0]; ?></a>
				<a href="supprMateriel.php?act=<?php echo $liens[1]; ?>" class="lienD"><?php echo $liens[1]; ?></a>
			</div>
<!-- // 			construction du tableau -->
			<table class="tabMat">
				<caption><?php echo $act;?></caption>
				<thead>
					<tr>
						<td>
							<a href="formMateriel.php?activite=<?php echo $act;?>">
								<img class="icone" src="images/icones/ajouter2.png" alt="ajouter" title="ajouter" />
							</a>
						</td>
					<?php 
// 				ecriture des titres de colonnes
					foreach($titres as $x){
						echo'<th>'.$x.'</th>';
					}?>
					</tr>
				</thead>
				<tbody>
				<?php 
				$req = materiel::getMaterielsByActivite($act);
				
				while ($res = $req->fetch()){
					echo('<tr>
							<td><input type="checkbox" name="idMat[]" value="'.$res['id'].'"/></td>
							<td>'.etiquette($tabType[$act], $res['type']).'</td>
							<td>'.etiquette($tabNiveau[$act], $res['niveau']).'</td>
							<td>');
								if ($res['marque']!=null) echo $res['marque'];
					echo('</td>
							<td>'.$res['taille'].'</td>
							<td>');
					if ($res['modele']!=null) echo $res['modele'];
					echo('</td>
				      	</tr>');
				}
				$req->closeCursor();
			?>	
				</tbody>
			</table>

				<p>
					<center> <input type="submit" name="envoyer" value="Supprimer" /> </center>
					<input type="hidden" name="action" value="supprimer" />
				</p>
			</form>
	</div>

	<div id="publicite">




	<?php include('includes/publicite.php'); ?>
	</div>
</body>
</html>
